<!DOCTYPE html>

<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">

<head>
	
<title></title>
	
<meta charset="utf-8">
	
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" href="jgp/css/project/ui-list-v3.css">
    
<link rel="stylesheet" href="jgp/css/project/ui-input-v3.css">
    
<link rel="stylesheet" href="jgp/css/project/ui-btn-v3.css">
    
<link rel="stylesheet" href="jgp/css/project/ui-res-v3.css">
    
<link rel="stylesheet" href="jgp/css/project/ui-color-v3.css">
	
<link rel="stylesheet" href="jgp/css/ui-color.css">
	
<link rel="stylesheet" href="jgp/css/ui-base.css">
	
<link rel="stylesheet" href="jgp/css/ui-box.css">
	
<link rel="stylesheet" href="jgp/css/ui-res.css">
	
<link rel="stylesheet" href="jgp/css/my.css">
	
<link rel="stylesheet" href="jgp/css/project/style.css">
	
<link rel="stylesheet" href="jgp/css/iBox.css">
	
	
<script src="jgp/js/zy_control.js"></script>
   
<script src="jgp/js/zy_click.js"></script>
    
<script src="jgp/js/common.js"></script>
    
<script src="jgp/js/zy_event.js"></script>
	
<script src="jgp/js/jquery-1.8.3.min.js"></script>
	
<script src="jgp/js/pbd.js"></script>
	
<script src="jgp/js/iBox.js"></script>
		
<script src="js/talkingdata.js"></script>
</head>

<body class="um-vp">
	
<div id="" class="ub ub-ver up">
	
<!--块容器开始-->
	
<div class="ub ub-ver  c-wh uinn5 umar-t1">
      
<!--块容器开始-->
		
<div class="ub c-wh uc-a uba ">
		    
<div class="ub-f1 uinn  c-blu t-wh uc-l1 tx-c" id="flight1" onclick="changeClor(this)">按航班</div>
		    
<div class="ub-f1 uinn  uc-r1 tx-c"  id="flight2" onclick="changeClor(this)">按航线</div>
		</div>
		<!--块容器结束-->

	</div>
	<!--块容器结束-->
    <!--块容器开始-->
<div class="ub ub-ver  uinn c-wh t-bla">
    <div class="ubb b-gra uinn ">
    	<!--文本输入开始-->
		<div class="ub ulab" id="filghtNo">
		    <div class="uinn ulim tx-l ub ub-ac ub-pc ub-f1 " id="xians">航班号</div>
		    <div class="ub-f1 c-wh  uinput uinn">
				<!--文本输入开始-->
				<div class="c-wh uinput uinn4 cu" id="hangban">
				    <input placeholder="请输入航班号 如：5677" type="text" id="flight" value="" class="uc-a1">
				</div>
				
		    </div>
		</div>
		<!--文本输入结束-->
	<div class="uhide  ulab "  id="filghtHX">
		<div class="uinn2 uc-a foup umh1-7 umar-r ub-img "></div>
			    <div class="ub-f1  uc-l1">
					<div class="ub ub-ver t-bla" onclick="getCity()">
					    <div class="uinn3 uc-t1">起飞城市</div>
					    <div class=" uinn3 uc-b1 passinfoba" id="qifei">上海虹桥</div>
						<div class=" uinn3 uc-b1 passinfoba uhide" id="qifei1">SHA</div>
					</div>
			    </div>
			    <div class="uinn2 uc-a res26 umh1-7 ub-img4" onclick="jiaohuan()"></div>
			    <div class="ub-f1  uc-r1">
					<div class="ub ub-ver t-bla tx-r" onclick="getCity1()">
					    <div class="uinn3 uc-t1 ">降落城市</div>
					    <div class="uinn3 passinfoba uc-b1" id="jiangluo">首都北京</div>
						 <div class="uinn3 passinfoba uc-b1 uhide" id="jiangluo1">PEK</div>
					</div>
			    </div>
				<div class="umar-l uinn2 uc-a down umh1-7 ub-img"></div>
		</div>

    </div>
    <div class="ubb b-gra uinn ">
    	<!-- 航班日期 --> 
				<!--列表开始-->
		<div class="c-wh umar-a">
			<div class="umar-l">航班日期</div>
		    <ul onclick="zy_touch('btn-act')" class="uc-t ub t-bla ub-ac lis">
		        <li class="res25 umh1-7 uinn1  umw1-7 ub-img"></li>
		        <li class="ut-s " id="day">哪天</li>
		        <li class="tx-c ub-f1   ulev0">
		        	 <div class="date cu" id="startDate">0000-00-00</div>
		        </li>
		        <li class=""  id="week">周几</li>    
		    </ul>
		</div>
		<!--列表结束-->
		<!-- 查询按钮 --> 
    </div>
	<div class="ubb b-gra uinn ">
    	<!--下拉列表开始-->
		<div class="ub t-bla uinn umar-a">
		    <div class="uinn ulim" >配备库房</div>
		    <div class="ub-f1 ub uba c-wh b-gra  sel">
		        <div class="ub-f1 ut-s uinn ulev-1 tx-l t-gra ulh-sel" id="kfmc">_</div>
		        <div class="ubl b-gra c-06 umw2 ub ub-pc ub-ac">
		            <div class="ub-img umw1 umh1 res3"></div>
		        </div>
		        <select name="sel0" selectedindex="0" id="pbk" onchange="zy_selectmenu(this.id)">
		        </select>
		    </div>
		</div>
		<!--下拉列表结束-->
    </div>
    <div class=" uinn5 uc-b1">
    	<!--按钮开始-->
     <div  id="flightNoUpload" class="btn uba b-org uinn11 c-org  t-wh  tx-c" onclick="showFlightNo()">航班查询</div>
	 <div id="hxNoUpload" class="btn uba b-org uinn11 c-org uhide t-wh  tx-c" onclick="showFlightHx()">航线查询</div>
       <!--按钮结束-->
    </div>
  </div>
</div>
<!--块容器结束-->
 <div id="diyLoadDiv" class="uhide" ></div>
</body>
<script>
    zy_init();
    window.uexOnload = function(type){
        if (!type) {
            setLocalLocation();
            createPbdTable();
            createPbdxdTable();
            createRecycle();
            getkfData();
			IC.talkingDataCount("机供品","0005");
        }
    }
    function getkfData(){
        var kf = JSON.parse(getStorage("kf"));
        var len = kf.length;
        for (var i = 0; i < len; i++) {
            var F_KFMC = kf[i].F_KFMC;
            var F_KFID = kf[i].F_KFID;
            if (i == 0) {
                $$("pbk").innerHTML += '<option selected="true" value=' + F_KFID + '>' + F_KFMC + '</option>';
            }
            else {
                $$("pbk").innerHTML += '<option value=' + F_KFID + '>' + F_KFMC + '</option>';
            }
        }
        $$("kfmc").innerHTML = $("#pbk").find("option:selected").text();
    }
    
    //查询方式切换改变样式及状态赋值
    function changeClor(obj){
        if (obj.id == "flight1") {
            $$("flight1").className = "ub-f1 uinn  c-blu t-wh uc-l1 tx-c";
            $$("flight2").className = "ub-f1 uinn  uc-r1 tx-c";
            $("#xians").text("航班号")
            $("#flight").attr('placeholder', '请输入航班号 如：5677')
            $$("filghtHX").className = "uhide  ulab";
            $$("filghtNo").className = "ub  ulab";
            $$("flightNoUpload").className = "btn uba b-org uinn11 c-org  t-wh  tx-c";
            $$("hxNoUpload").className = "uhide";
            
        }
        else {
            $$("flight1").className = "ub-f1 uinn  uc-l1 tx-c";
            $$("flight2").className = "ub-f1 uinn  c-blu t-wh uc-r1 tx-c";
            $$("filghtHX").className = "ub  ulab";
            $$("filghtNo").className = "uhide  ulab";
            $$("hxNoUpload").className = "btn uba b-org uinn11 c-org  t-wh  tx-c";
            $$("flightNoUpload").className = "uhide";
        }
    }
    
    iP = {};
    //页面初始化
    iP.init = function(){
        //初始化->开始日期
        iP.initialDate();
        //绑定->日期控件
        $("#startDate").on("click", iP.openDate);
    };
    iP.initialDate = function(){
        //初始化->开始日期
        var newdate = new Date();
        var newtimems = newdate.getTime();
        newdate.setTime(newtimems);
        iP.setDate($("#startDate"), iG.getYear(newdate), iG.getMonth(newdate), iG.getDay(newdate));
    };
    //打开日期控件
    iP.openDate = function(){
        var that = $(this);
        var date = JSON.parse(that.attr("date"));
        iG.openDate(date.year, date.month, date.day, function(data){
            iP.setDate(that, data.year, data.month, data.day);
        })
    };
    //设置日期、星期
    iP.setDate = function(elem, year, month, day){
        var json = {
            "year": year,
            "month": month,
            "day": day,
        }
        elem.text(year + "-" + month + "-" + day);
        elem.attr("date", JSON.stringify(json));
        elem.attr("need", year + "-" + month + "-" + day);
        var today = year + "-" + month + "-" + day;
        var zuo = getDay(-1);
        var jin = getDay(0);
        var ming = getDay(1);
        if (today == zuo) {
            $("#day").text("昨天");
        }
        else 
            if (today == jin) {
                $("#day").text("今天");
            }
            else 
                if (today == ming) {
                    $("#day").text("明天");
                }
                else {
                    $("#day").text("");
                }
        
        var weekDay = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
        var dateStr = (year + "-" + month + "-" + day);
        var myDate = new Date(Date.parse(dateStr.replace(/-/g, "/")));
        $("#week").text(weekDay[myDate.getDay()]);
        
    };
    function getDay(day){
        var today = new Date();
        var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
        today.setTime(targetday_milliseconds); //注意，这行是关键代码  
        var tYear = today.getFullYear();
        var tMonth = today.getMonth();
        var tDate = today.getDate();
        tMonth = doHandleMonth(tMonth + 1);
        tDate = doHandleMonth(tDate);
        return tYear + "-" + tMonth + "-" + tDate;
    }
    
    function doHandleMonth(month){
        var m = month;
        if (month.toString().length == 1) {
            m = "0" + month;
        }
        return m;
    }
    
    iP.init();
    
    /****************查询提交*********************/
    function showFlightNo(){
        setStorage('uploadType', '');//判断当前为航班号查询
        var dataTime = $("#startDate").text();//获取时间段
        setStorage("dateTime", dataTime);
        var flight = $$("flight").value;
        if (!flight) {
            $.iBoxMsg("请输入查询航班");
            return;
        }
        else {
            setStorage("flightNo", flight);
        }
        var kfid = $("#pbk").val();
        setStorage("kfid", kfid);
        var param = {
            "userID": getStorage("userId"),
            "dateTime": dataTime,
            "flightNo": flight,
            "kfid": kfid
        };
        $.iBoxWait();
        $.ajax({
            url: flightUrl,
            type: "post",
            data: param,
            dataType: "json",
            success: function(data){
                if (data.status == 0) {
                    var successObj = 0;
                    if ((data.array).length > 0) {
                        for (var i = (data.array).length - 1; i > -1; i--) {
                            queryPbd((data.array)[i], function(queryObj){
                                if (queryObj == 0) {
                                    successObj++;
                                }
                                if (successObj == (data.array).length) {
                                    uexWindow.open("FlightJGP", 0, "jgp_FlightJGP.html", 2, "", "", 0);
                                    $.iBoxHide();
                                }
                            })
                            initPbdxd((data.array)[i].F_PBDBH);//调用详单表新增方法
                        }
                    }
                    else {
                        uexWindow.open("FlightJGP", 0, "jgp_FlightJGP.html", 2, "", "", 0);
                        $.iBoxHide();
                    }
                }
                else 
                    if (data.status == 1) {
                        $.iBoxMsg(data.desc);
                    }
                    else {
                        $.iBoxMsg("服务器无响应");
                    }
            },
            error: function(data){
                $.iBoxHide();
                var mycars = ['确认', '取消'];
                uexWindow.confirm("当前网络异常...", "是否进入离线模式操作？", mycars);
                uexWindow.cbConfirm = function confirmCallback(opId, dataType, data1){
                    if (data1 == 0) {
                        uexWindow.open("FlightJGP", 0, "jgp_FlightJGP.html", 2, "", "", 0);
                    }
                };
            }
        })
    }
    
    function showFlightHx(){
        setStorage('uploadType', 'hx');//判断当前未航线查询
        var dataTime = $("#startDate").text();//获取时间段
        setStorage("dateTime", dataTime);
        var flightNo = $("#qifei1").text() + "-" + $("#jiangluo1").text();
        setStorage("flightNo", flightNo);
        var kfid = $("#pbk").val();
        setStorage("kfid", kfid);
        var param = {
            "userID": getStorage("userId"),
            "dateTime": dataTime,
            "flightNo": flightNo,
            "kfid": kfid
        };
        $.iBoxWait();
        $.ajax({
            url: flightHXUrl,
            type: "post",
            data: param,
            dataType: "json",
            success: function(data){
                if (data.status == 0) {
                    var successObj = 0;
                    if ((data.array).length > 0) {
                        for (var i = (data.array).length - 1; i > -1; i--) {
                            queryPbd((data.array)[i], function(queryObj){
                                if (queryObj == 0) {
                                    successObj++;
                                }
                                if (successObj == (data.array).length) {
                                    uexWindow.open("FlightJGP", 0, "jgp_FlightJGP.html", 2, "", "", 0);
                                    console.log("配备添加完成" + (data.array).length);
                                    $.iBoxHide();
                                }
                            })
                            initPbdxd((data.array)[i].F_PBDBH);//调用详单表新增方法
                        }
                    }
                    else {
                        uexWindow.open("FlightJGP", 0, "jgp_FlightJGP.html", 2, "", "", 0);
                        loadingEnd();
                    }
                }
                else 
                    if (data.status == 1) {
                        $.iBoxMsg(data.desc);
                    }
                    else {
                        $.iBoxMsg("服务器无响应");
                    }
            },
            error: function(data){
                loadingEnd();
                var mycars = ['确认', '取消'];
                uexWindow.confirm("当前网络异常...", "是否进入离线模式操作？", mycars);
                uexWindow.cbConfirm = function confirmCallback(opId, dataType, data1){
                    if (data1 == 0) {
                        uexWindow.open("FlightJGP", 0, "jgp_FlightJGP.html", 2, "", "", 0);
                    }
                };
            }
        })
    }
    
    /********获取起降城市***********/
    function getCity(){
        uexWindow.evaluateScript('', '0', 'changeTop(1)');
        var path = "jgp/res/citys.png";//保存城市列表信息的文件路径
        var DHcity = 0;//城市列表窗体状态标识（打开OR关闭）
        var s = window.getComputedStyle(document.body, null);
        var headerHeight = getStorage('headerHeight');
        uexDHCity.open(0, headerHeight, int(s.width), int(s.height), path, '输入要查找的城市名或三字码', '热门城市');
        uexDHCity.cbSelected = function(opId, dataType, data){
            setStorage('saveSelCity', data);//保存选中的城市信息
            //延时关闭城市列表窗体
            setTimeout(function(){
                uexDHCity.close();
                DHcity = 0;
                setCity(1);
            }, 200);
        }
        DHcity = 1;
    }
    
    function closeWin(){
        uexDHCity.close();
		IC.talkingDataCount("机供品","0005");
    }
    
    function getCity1(){
    
        uexWindow.evaluateScript('', '0', 'changeTop(1)');
        
        var path = "jgp/res/citys.png";//保存城市列表信息的文件路径
        var DHcity = 0;//城市列表窗体状态标识（打开OR关闭）
        var s = window.getComputedStyle(document.body, null);
        var headerHeight = getStorage('headerHeight');
        uexDHCity.open(0, headerHeight, int(s.width), int(s.height), path, '', '热门城市');
        uexDHCity.cbSelected = function(opId, dataType, data){
            setStorage('saveSelCity', data);//保存选中的城市信息
            //延时关闭城市列表窗体
            setTimeout(function(){
                uexDHCity.close();
                DHcity = 0;
                setCity(2);
            }, 200);
        }
        DHcity = 1;
    }
    
    //获取选择 的城市
    function setCity(type){
        uexWindow.evaluateScript('', '0', 'changeTop(3)');
        var city = JSON.parse(getStorage('saveSelCity'));
        var cityName = (city.name).substring(4, (city.name).length);
        if (type == 1) {
            $("#qifei").text(cityName);//保存选中的城市信息
            $("#qifei1").text(city.code);//保存选中的城市信息
        }
        else {
            $("#jiangluo").text(cityName);//保存选中的城市信息
            $("#jiangluo1").text(city.code);//保存选中的城市信息
        }
    }
    
    //起降城市及三字码进行数据切换
    function jiaohuan(){
        var city = '';
        var city1 = '';
        city = $("#qifei").text();
        $("#qifei").text($("#jiangluo").text());
        $("#jiangluo").text(city);
        
        city1 = $("#qifei1").text();
        $("#qifei1").text($("#jiangluo1").text());
        $("#jiangluo1").text(city1);
        
    }
    
    //在配备单页面就将详单的信息写入本地详单表 、回收表单新增
    function initPbdxd(obj){
        var param = {
            "F_PBDBH": obj
        };
        $.ajax({
            url: getPeiBeiDanUrl,
            type: "post",
            data: param,
            dataType: "json",
            success: function(data){
                if (data.status == 0) {
                    queryPbdxd(obj, data.array);
                }
                else 
                    if (data.status == 1) {
                        $.iBoxMsg(data.desc);
                    }
                    else {
                        $.iBoxMsg("网络异常，请重试");
                    }
            },
            error: function(data){
                $.iBoxMsg("服务器无响应");
            }
        })
    }
</script>
</html>
